package kr.hkit.powerjava.chapter26.Young;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DbUtil { // 클로즈용

	public static void close(Connection con) {
		if (con != null) {
			try {
				con.close();
			} catch (SQLException e) {
				System.err.println(e);
			} finally {
				con = null;
				System.out.println("MySQL Connection Close!!");
			}
		}
	}

	public static void close(PreparedStatement pstmt) {
		if (pstmt != null) {
			try {
				pstmt.close();
			} catch (SQLException e) {
				System.err.println(e);
			} finally {
				pstmt = null;
			}
		}
	}

	public static void close(ResultSet rs) {
		if (rs != null) {
			try {
				rs.close();
			} catch (SQLException e) {
				System.err.println(e);
			} finally {
				rs = null;
			}
		}
	}

	public static void close(PreparedStatement pstmt, ResultSet rs) {
		DbUtil.close(pstmt, rs);
	}

}
